import tkinter

def  func():
    print("壮哥 is cool man!!!")


if __name__ == "__main":
    #创建主窗口
    win = tkinter.Tk()
    #设置标题
    win.title('安然')
    #设置大小400x400和位置200 0 
    win.geometry('400x400+200+0')

    #进入消息循环
    '''
    Label:标签控件可以显示文本
    '''
    #参数: win父窗体, text 显示文本内容 bg 背景色 fg 字体颜色 wraplength指定text文本中多宽进行换行 anchor 位置 n 北, e东, s 南 w西 center居中, es东南
    # label = tkinter.Label(win,text=" 安然 cool",bg='red',fg='yellow',font=('黑体',20),width=10,height=5,wraplength=100,justify="left",anchor='w')
    button = tkinter.Button(win,text= '按钮',command=func,width=20,height=5)
    button.pack()
    #command绑定点击事件
    button1 = tkinter.Button(win, text = '按钮',command=win.quit)
    button1.pack()
    button2 = tkinter.Button(win, text = '输出',command=lambda: print(e.get()))
    button2.pack()
    #显示出来
    # label.pack()
    '''
    Entry 输入控件,用于显示简单的文本
    '''
    #绑定变量
    e = tkinter.Variable()
    #show 密文显示 无论输入什么显示*show='*'
    entry = tkinter.Entry(win,textvariable=e)
    #e 代表输入框
    #设置值,不能使用entry
    e.set('anran is cool man')
    #取值
    print(e.get()) 
    print(entry.get())
    entry.pack()


    '''
    text
    文本控件,用于显示多行文本
    '''
    #创建滚动条
    scroll= tkinter.Scrollbar()
    #height 显示的行数

    text = tkinter.Text(win,width=30,height=4)
    #side放到窗体的那一侧 fill 填充,
    scroll.pack(side=tkinter.RIGHT,fill=tkinter.Y)
    text.pack(side=tkinter.LEFT,fill=tkinter.Y)
    #关联
    scroll.config(command=text.yview)
    text.config(yscrollcommand=scroll.set)
    str = '''jdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsfdlsajfljslkdajfsdhflhsalfhlksafhldshflkhaslfalsfjdslfdsjf;ldsjf;lajdfjas;lfja;fj;lasjf;jsaflkjafljsafldshflshflksjf;jwfjoiahsfdshlkfhsalfhflhaflkfhslkdfhlfhlksfhlfhslfhfhflkfhflkshflsfhslfhsf'''
    text.insert(tkinter.INSERT,str)


    win.mainloop()





